#include <bits/stdc++.h>

using namespace std;

const int N = 1005;
char str[N], pattern[N];
int Next[N];
int cnt = -1;

void getNext(char *p, int plen){
    Next[0] = 0;
    Next[1] = 0;
    for(int i = 1; i < plen; i++){
        int j = Next[i];
        while(j && p[i] != p[j])
            j = Next[j];
        if(p[i] == p[j]) Next[i+1] = j+1;
        else Next[i+1] = 0;
    }
}

void kmp(char *s, char *p)
{
    int last = -1;
    int slen = strlen(s), plen = strlen(p);
    getNext(p, plen);
    int j = 0;
    for(int i = 0; i < slen; i++)
    {
        while(j && s[i] != p[j])
            j = Next[i];
        if(s[i] == p[j]) j++;
        if(j == plen){
            cnt = i+1 - plen;
            break;
        }
    }
}

int main()
{
    scanf("%s", str);
        scanf("%s", pattern);
        kmp(str, pattern);
        cout << cnt;
}